/* =========================================================================
 * File: Get.java$
 *
 * Modified by Saverio Miroddi
 *
 * =========================================================================
 * Copyright 2006 by Yuriy Stepovoy.
 * email: stepovoy@gmail.com
 * All rights reserved.
 * =========================================================================
 */
package net.sf.cache4j.perfomance.test;

import net.sf.cache4j.perfomance.cache.ICacheTest;

public class Get implements ITest {

    private static final String NAME = "Get";

    private static final int CYCLES = 1000;
    
    private static final int TOT_KEYS = 2000;
    private static final int KEYS_RANGE = 2000;

    private static String[] KEYS = Utils.getRandomKeys(TOT_KEYS, KEYS_RANGE);

    private ICacheTest cache;

    public void init(ICacheTest cache) throws Exception {
        this.cache = cache;
        for (String key: KEYS) cache.put(key, key);
    }

    public void test() throws Exception {
    	for (int i = 0; i < CYCLES; i++) {
    		for (String key: KEYS) cache.get(key);
    	}
    }

    public String getName() {
        return NAME;
    }

	public void destroy() {
		cache.destroy();
	}
}